package mapkit.layers
{
	import mapkit.MapEvent;

	public class DynamicImageLayer extends ImageLayer
	{
		protected var image:MapImage=null;

		override protected function updateMap(event:MapEvent=null):void
		{
			super.updateMap(event);

			if (!image)
			{
				image=new imageClass();
			}

			if (!contains(image))
			{
				addChild(image);
			}

			invalidateDisplayList();
		}

		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			super.updateDisplayList(unscaledWidth, unscaledHeight);

			if (image && contains(image) && map && baseURL.length > 0)
			{
				image.url=baseURL;
				image.extent=map.extent;
				image.width=map.width;
				image.height=map.height;
				image.invalidateDisplayList();
			}
		}
	}
}
